<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0px;
      padding:0px;
    }
    ul{
      list-style: none;
    }
    .wrap{
      width:330px;
      height:30px;
      margin: 100px auto 0;
      padding-left: 10px;
      background-image: url('imgs/bg.jpg');
    }
    .wrap li{
      background-image: url('imgs/libg.jpg');
    }
    .wrap>ul>li{
      float: left;
      margin-right: 10px;
      position: relative;
    }
    .wrap a{
      display: block;
      height: 30px;
      width: 100px;
      text-decoration: none;
      color:#000;
      line-height: 30px;
      text-align: center;
    }
    .wrap li ul{
      position: absolute;
      top:30px;
      display: none;
    }
  </style>
</head>
<body>
  <script src="../../jquery-1.12.4.min.js"></script>
  <script>
    //jquery入口函数
    $(document).ready(function(){
      //给要操作的li设置移入事件
      $('.wrap > ul > li').mouseenter(function(){
        //获取内部子元素 ul,设置为显示
        //因为是遍历的元素所以要使用this，this表示事件源，但是this是DOM对象形式，所以要用$()包裹下转成jQuery对象形式 
        console.log(this)
        $(this).children('.ul').show();
      })
      //给li设置移出事件：可以通过链式编程写法设置成一句代码
      .mouseleave(function(){
        $(this).children('.ul').hide()
      });
    });
  </script>
  <div class="wrap">
    <ul>
      <li>
        <a href="javascript:;">一级菜单1</a>
        <ul class="ul">
          <li><a href="javascript:;">一级菜单11</a></li>
          <li><a href="javascript:;">一级菜单11</a></li>
          <li><a href="javascript:;">一级菜单11</a></li>
        </ul>
      </li>
      <li>
        <a href="javascript:;">二级菜单1</a>
        <ul class="ul">
          <li><a href="javascript:;">二级菜单22</a></li>
          <li><a href="javascript:;">二级菜单22</a></li>
          <li><a href="javascript:;">二级菜单22</a></li>
        </ul>
      </li>
      <li>
        <a href="javascript:;">三级菜单3</a>
        <ul class="ul">
          <li><a href="javascript:;">三级菜单33</a></li>
          <li><a href="javascript:;">三级菜单33</a></li>
          <li><a href="javascript:;">三级菜单33</a></li>
        </ul>
      </li>
    </ul>
  </div>
</body>
</html>